﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CloudClass.Models;
using Orchard.Data;

namespace CloudClass.Services
{
    public class TopNotesService:ITopNotesService
    {
        private readonly IRepository<NotesTop> _askRepository;
        //private readonly IEnumerable<ICarEventHandler> _handlers; 
        public TopNotesService(IRepository<NotesTop> evalutionRepository)
        {
            _askRepository = evalutionRepository;
            //_handlers = handlers;
        }

        public virtual bool Create(Models.NotesTop model)
        {

            try
            {
                _askRepository.Create(model);
            }
            catch
            {
                return false;
            }
            return true;
        }

        public virtual bool Edit(NotesTop model)
        {
            try
            {
                _askRepository.Update(model);
            }
            catch
            {
                return false;
            }
            return true;
        }

        public virtual bool Delete(int[] array)
        {
            try
            {
                foreach (var id in array)
                {
                    var item = this.Get(id);
                    _askRepository.Delete(item);
                }
            }
            catch
            {
                return false;
            }
            return true;
        }

        public virtual NotesTop Get(int id)
        {
            var item = _askRepository.Get(id);
            return item;
        }

        public virtual List<NotesTop> GetList()
        {
            return _askRepository.Table.ToList();
        }

        public virtual object List(out int count)
        {
            var list = _askRepository.Table.ToList();
            count = list.Count;
            return list;
        }
    }
}